#ifndef XGE_XBASE_COMMON_H_
#define XGE_XBASE_COMMON_H_
#include "xge_common_config.h"
#include "xassert.h"

namespace xge{

  // Tripe Result
  // This is the addition for the bool type
  class TripleResult{
  public:
    enum {
      EXCEPTION = -1,
      FAILED    = 0,
      SUCCEDED  = 1
    };
  public:
    bool Exception() const { return val_ == TripleResult::EXCEPTION ; }
    bool Failed  () const { return val_ == TripleResult::FAILED ; }
    bool Succeded () const { return val_ == TripleResult::SUCCEDED; }

    operator bool() const {
      return Succeded() == true;
    }
  public:
    TripleResult():val_( TripleResult::EXCEPTION ){}
    EXPLICIT_CTOR(TripleResult,int val){
      // Check
      XASSERT( val>= TripleResult::EXCEPTION && val<= TripleResult::SUCCEDED );
      val_=val;
    }
  public:
    TripleResult(const TripleResult& inst):val_(inst.val_){}
    const TripleResult& operator=( const TripleResult& inst){
      if( this == &inst ) {
        return *this;
      }
      val_ = inst.val_;
      return *this;
    }
  public:
    bool operator == ( const TripleResult& inst ) const {
      return val_ == inst.val_;
    }
    bool operator == ( int val ) const {
      return val_ == val;
    }
    bool operator != ( const TripleResult& inst ) const {
      return !((*this) == inst );
    }
    bool operator != ( int val ) const {
      return !((*this) == val );
    }
  public:
    static const TripleResult kFailed;
    static const TripleResult kException;
    static const TripleResult kSucceded;
  private:
    int val_;

    TripleResult(int value,int dummy) {
      DUMMY_ARG(dummy);
      val_ = value;
    }

  };
  
} // namespace xge

#endif// XGE_XCOMMON_H_